package com.example.dubbo.config.redisson;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

/**
 * Redisson配置
 *
 * @author NiJo_H
 * @version 1.0
 */
@Configuration
public class RedissonConfig {

    /**
     * 单机模式
     *
     * @deprecated redisson-single 单列
     * redison-master-slave 主从
     * redisson-cluster    集群
     * redisson-sentine   哨兵
     * 需要配置模式更换yml即可
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws IOException {
        RedissonClient redisson = Redisson.create(
                Config.fromYAML(new ClassPathResource("redisson-single.yml").getInputStream()));
        return redisson;

    }
}
